package jw3.c2.controller;

<<<<<<< HEAD
public class VipController {
=======
import com.sun.jmx.snmp.SnmpString;
import jw3.c2.model.Vip;
import jw3.c2.utils.DBConnection;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;
import java.util.Vector;

public class VipController {
    //增
    public boolean register(Vip vip) {
        return true;
    }

    //删
    public boolean logOut(int id) {
        return true;
    }

    //改
    public static boolean edit( Vip vip) {

        String sql="update vip set Vip_Type=?, Vip_DisCount =? where Vip_ID=?";
        return DBConnection.zsg(sql,vip.getVip_Type(),vip.getVip_DisCount(),vip.getVip_ID());
    }

    //全查
    public static Vector<Vector<Object>> getAll(){
        String sql="SELECT * FROM vip;";
        //1、构造Vector类型用于赋值给表格
        Vector<Vector<Object>> data3=new Vector<Vector<Object>>();
        try {
            Connection conn= DBConnection.getConnection();
            PreparedStatement ps=conn.prepareStatement(sql);
            ResultSet rs= ps.executeQuery();
            while (rs.next()){
                // //创造对象，每次放一条数据
                Vector<Object> v=new Vector<Object>();

                //将每个字段放入对象
                v.add(rs.getInt("Vip_ID"));
                v.add(rs.getString("Vip_Type"));
                v.add(rs.getDouble("Vip_DisCount"));
                //每次将一条数据加入到集合
                data3.add(v);
            }
            DBConnection.close(rs,ps,conn);
            return data3;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
}

>>>>>>> 41a53c21de81f762a7a7e8110a6b6a114ea5d254
}
